/*
 * Copyright 2016-2019 yoara
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package yhao.infra.feature.payment.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import yhao.infra.feature.payment.ConfigFactory;
import yhao.infra.feature.payment.core.alipaynew.AliPayService;
import yhao.infra.feature.payment.core.wxpay.WeiXinPayService;

/**
 * 配置demo
 *
 * @author yoara
 */
public class PayDemo {
    @Autowired
    private Environment env;

    @Bean(name="aliPayService")
    public AliPayService alipayService(){
        return ConfigFactory.makeAliPayService(env.getProperty("alipay.notify_url_pre"),
                env.getProperty("alipay.return_url"),env.getProperty("alipay.gateway"),
                env.getProperty("alipay.seller_id"),env.getProperty("alipay.app_id"),
                env.getProperty("alipay.app_private_key"),env.getProperty("alipay.ali_public_key"),
                env.getProperty("alipay.time_out_express"));
    }

    @Bean(name="weiXinPay")
    public WeiXinPayService weiXinPay() throws Exception {
        return ConfigFactory.makeWeiXinPayService(env.getProperty("weixin.pay.app_id"),
                env.getProperty("weixin.pay.partner_id"),env.getProperty("weixin.pay.partner_key"),
                env.getProperty("weixin.pay.notify_url_pre"),env.getProperty("weixin.pay.wap_url"),
                env.getProperty("weixin.pay.wap_name"),env.getProperty("weixin.pay.uniform_order_url"),
                env.getProperty("weixin.pay.refund_url"),env.getProperty("weixin.pay.refund_query_url"),
                env.getProperty("weixin.pay.redirect_url"),env.getProperty("weixin.pay.credentials_name"),
                env.getProperty("weixin.pay.pay_query_url"));
    }
}
